﻿using System;
using System.Collections.Generic;
using Me.Prettyprint.Cassandra.Serializers;
using Me.Prettyprint.Cassandra.Service;
using Me.Prettyprint.Cassandra.Utils;
using Me.Prettyprint.Hector.Api;
using Me.Prettyprint.Hector.Api.Beans;
using Me.Prettyprint.Hector.Api.Factory;
using Me.Prettyprint.Hector.Api.Query;
using Org.Apache.Cassandra.Thrift;

namespace Me.Prettyprint.Cassandra.Model.Thrift
{
    /// <summary>
    /// Counts super column for a of a key in a super column family
    /// </summary>
    /// <typeparam name="K"></typeparam>
    /// <typeparam name="SN"></typeparam>
    public class ThriftSuperCountQuery<K, SN> : AbstractThriftCountQuery<K, SN>, SuperCountQuery<K, SN>
    {
        public ThriftSuperCountQuery(Keyspace keyspace, Serializer<K> keySerializer,
            Serializer<SN> sNnameSerializer) :
            base(keyspace, keySerializer, sNnameSerializer)
        {
        }
        public override QueryResult<int> Execute()
        {
            return CountColumns();
        }
        public override string ToString()
        {
            return "SuperCountQuery(" + ColumnFamily + "," + Key + ")";
        }
        public new SuperCountQuery<K, SN> SetKey(K key)
        {
            return (SuperCountQuery<K, SN>) base.SetKey(key);
        }
        public new SuperCountQuery<K, SN> SetColumnFamily(string cf)
        {
            return (SuperCountQuery<K, SN>) base.SetColumnFamily(cf);
        }
        public new SuperCountQuery<K, SN> SetColumnNames(List<SN> columnNames)
        {
            return (SuperCountQuery<K, SN>) base.SetColumnNames(columnNames);
        }
        public new SuperCountQuery<K, SN> SetRange(SN start, SN finish, int count)
        {
            return (SuperCountQuery<K, SN>) base.SetRange(start, finish, count);
        }
    }
}
